package com.xcdh.learn.commons;

import com.xcdh.domain.vo.R;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class GlobalErrorController implements ErrorController {


    @RequestMapping("/error")
    public R handlerError(NoSuchFieldException e , HttpServletRequest request){
        System.out.println(request.getRequestURL());
        return R.error(StateCode.NOTSOURCE ,"404 访问资源不存在");
    }
}
